- All Annotations 43
- John Resig 40
- figital 1
- httpJunkie 1
- kopiro 1
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusNote: This may not be the first first code released, but it appears to be the earliest copy that we’ve found, so far. This is a copy that was indexed by the Internet Archive on Feb 3rd 2006, so about 2.5 weeks after the initial release. It’s very likely that a few things changed in that time period and I’ll try to make a note of some of those, that I can remember, inline.
This video is processing – it'll appear automatically when it's done.
I’ll also note that the reason why we don’t have the first version was because I didn’t keep jQuery in source control! I was just kind of hacking around and didn’t think much of it. It wasn’t until I started to get contributions (or interest in contributions) that I put it in to SVN.
agreed, if things are in version, it will just slow down the hacking mood.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusMy post-mortem blog post where I announce what I released at BarCamp NYC:
John Resig - BarCampNYC Wrap-up
jQuery was just one of a couple projects that I had been working on! After the release at Barcamp I did a lot to try and promote the library, mostly on Digg and Delicious (which were the two top places for promoting links at that time).
https://previous.delicious.com/url/32b2c30383abf5f586d72c1bf6cccab1
You can read more about the history of jQuery here:
History | jQuery Foundation
This video is processing – it'll appear automatically when it's done.
I have vague memories of sharing a floor at House 2.0 (Amit’s apartment) the night before while you were putting some finishing touches on it.
Seth: Great memory – yes, that’s exactly right!
@Iborgav: Oh god, when I came to college I had to come up with a username. My computer names were like ‘anthrax’ and the like, and I found ‘Phytar 560’ as a herbal pesticide so I went with it. Didn’t use it for very long, maybe just a couple years until I switched back to just ‘jeresig’.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusThe first release of jQuery didn’t include any Ajax functionality! Truth-be-told I found that I really didn’t need a separate Ajax library for the projects I was working on and it wasn’t until I had gotten a number of requests from users that I then wrote a brand-new one and included it in jQuery. jQuery 1.0 had Ajax built-in natively.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusOn initial release jQuery was broken up into a couple modules. One of those modules was the ‘FX’ module which allowed you to do all sorts of animations. This was a library that I had written as a fork/clone of the moo.fx library (which later went on to become MooTools).
You can see the original FX source in the Internet Archive:
https://web.archive.org/web/20060205022911/http://jquery.com/src/minifx/minifx-latest.js
jQuery was essentially birthed from three libraries that I had written: A JavaScript CSS selector library, a moo.fx-like animation library, and an easy-to-use addEvent/removeEvent implementation. I combined all of these together into a simple API that was largely inspired by Prototype and the Behaviour library and here we go – the rest is history, so to speak!
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusThis module contained a bunch of nice events functionality, virtually all of which was later integrated into jQuery core:
https://web.archive.org/web/20060205034528/http://jquery.com/src/event/event-latest.js
Probably the biggest item here is the initial implementation of the .ready() method – one of the early attempts to try and make truly-progressive JavaScript that dynamically updated the DOM after load. This was actually a pretty big thing that jQuery promoted as most libraries expected you to run after window.onload or insert yourself into the very bottom of the page and then running immediately. jQuery was different because it promoted using progressive layering – passing down a functional page and then once the DOM was ready going through and updating it with JavaScript.
Note that the initial ready implementation is quite poor. A lot of iteration was happening on this concept. You can see Dean Edwards' blog post on the subject here:
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI guess it took me a little bit to develop the now-preferred ‘jQuery’ capitalization! I originally called this library “JSelect” (for selecting elements out of the page, plus it started with JS, which was nice). However the domain name jselect.com wasn’t available, thus I had to find another name.
This video is processing – it'll appear automatically when it's done.
whoa thank goodness jselect.com wasn’t available lol!
John, do you remember the other JQuery? I think it was a Java library of some sort, and it actually was capitalized “JQuery”. I recall kidding you about the name in the early months of the jQuery mailing list.
I tried to do a search for the other JQuery, but as you can imagine it was not an easy name to Google any more… :-)
Yes! I did find their project, on Sourceforge, before I released my jQuery but at the time it appeared to be dormant (if memory serves me correctly at the time it hadn’t been updated in a few years). Soon after I released jQuery they actually made an update to their code, indicating that it was still alive. We ended up having a conversation at one point about the unfortunate name collision but it seemed like their project never got major traction (or was prevented from gaining traction by my project – I’m not sure).
Now I think the other project was capitalized “Jquery”.
And I distinctly recall someone on the very early jQuery mailing list who kept calling it “JQUERY”, just like when someone says LUA or PASCAL. I tried to very gently mention that it was spelled “jQuery”, which didn’t go over too well. He started going through my resume to see if I’d ever made a mistake, and sure enough, I had!
Live and learn… :-)
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusEven though the domain was available there apparently was another project (a Java SQL library) named jQuery. They had owned this domain a while back but had let it lapse. I only found this out later after they contacted me to let me know about the name conflict! I felt bad, I had definitely wanted to avoid causing any confusion!
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusThe very first release of jQuery (and for the next few months of releases) was under a Creative Commons license. I had released tons of open source projects before this point but I hadn’t put a license on anything as no one had ever asked for one! (Probably says something about how many people used them, ha!) In retrospect a CC license is a poor choice for code and I switched to using an MIT license pretty soon after.
At one point I went back and looked at the open source projects that I had released before jQuery. I counted 75 projects before this one! Before jQuery my most famous works were: A browser bookmarklet for easily saving links to Delicious (called LazySheep), a tool for navigating Wikipedia edit history (with which I won 2nd place in a contest), and a mini-library for binding events to DOM elements (which won 1st place in a contest and will talk about later as it influenced jQuery!).
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusThe infamous ‘$’! This, along with a lot of the functionality in jQuery, is directly inspired by the Prototype JavaScript library. The library was bundled with Rails, which was super-hot in 2005, when I was developing this library, and I loved a lot of the techniques that they were promoting. I aspired to have jQuery be a drop-in library that you could use side-by-side with Prototype.
This video is processing – it'll appear automatically when it's done.
It looks like that was added in jQuery 1.1, which was released one year later in 2007.
https://code.jquery.com/jquery-1.1.js
I remember using prototype back in 2008, and soon after discovered jQuery, I have never looked back since. I still believe jQuery is a premium underlying framework to make your JS development so much more sophisticated and lean. You’re a protege of Douglas Crockford right?
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by Geniusjust trying the genius tool. for a n00b looking at this code … what is a and c? (not the point of john’s annotations … just curious what else this could do diving in and out of “words”). also curious to see how the annotation “threads” are sorted.
This video is processing – it'll appear automatically when it's done.
a and c are parameters or arguments that are passed as inputs into this anonymous function. Your selection checks to see if anything was passed in for the ‘a’ argument
yes … i meant to perhaps highlight “a,c” above but that text already had a thread. in this case a==selector and c==context/element … /// perhaps links to examples, documentation, discussion of why these varnames were used, etc.
Well, yeah, it’s the first thing in jQuery documentation ;)
jQuery() | jQuery API Documentation
i’ve certainly dabbled in jQuery over the years. i don’t remember having used or seen that second parameter until diving under the hood here a little.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusA concept that attempts to make future releases of a project not directly conflict with it’s previous versions otherwise known as a “Breaking Changes”.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusWe start to see some of the Prototype-specific functionality. We also see where some of the functionality starts to crumble. I wanted to provide a better implementation of their ‘$(…)’ function (which, by default, took a string and returned a DOM element that had that ID). I wanted to make ‘$(…)’ be able to handle that case AND be able to take both CSS and XPath selectors, too! You can start to see where this abstraction crumbles down as sometimes you’ll get a DOM element and sometimes you’ll get a jQuery object.
Additionally you get the weird edge case where if you have ‘$(“body”)’ – what is supposed to be returned? The body element? The element with an ID of body? Yeah, this wasn’t a great idea and it was gone before 1.0 was released.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusA major blunder. Instead of just making a jQuery function that was instantiated (and thus inherited its prototype) I instead made a new object every time with the relevant properties stuck in. This was corrected pretty soon after, I believe before 1.0 was released.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusSo this may look crazy – it certainly does to me! Why not just do: f.call(this._get(i))
? If I remember correctly, and I just did some double-checking and I think this is the case, but IE 5 didn’t support .call()
! The original version of jQuery event worked back to IE 5… I can hardly believe. I think we ended up dropping support for IE 5 pretty soon after and “upgraded” to IE 6, which made stuff like this obsolete.
This video is processing – it'll appear automatically when it's done.
Shouldn’t the code in your annotation say f.call(this._get(i), i)? Or am I getting something wrong?
@DHainzl: You’re right – just a typo :)
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusThis was later re-named into ‘.attr()’, since having another method named .get()
(which gave you a DOM element) didn’t really make sense.
This video is processing – it'll appear automatically when it's done.
I notice you use a lot of non-descriptive parameters, such as a
and b
. Is there a particular reason, or just one of those “I’m writing this quick and dirty and it makes sense to me” and you weren’t thinking about people trying to read the code afterwards?
Was this perhaps before minification was common and you were worried about bytes?
Cameron: Totally just quick and dirty and made sense to me :) I think I mentioned that in an other annotation. This early code was pretty much only being used by me!
Cameron: This is actually pretty typical left/right behavior. There are basically three types of devs in this regard. You either do (a,b), (left,right) -or- (l,r), or finally you choose a pair of names that mean something to you. notice that the (a,b) syntax is simple and doesn’t require you to do a lot of work, especially when you don’t know the objects that will be passed in. When I see that nomenclature I know that this is going to be dynamic and I shouldn’t know what’s happening here.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusSo this is almost certainly not the first first release of the library as there are already deprecated methods. Deprecated after two weeks! Code moves so quickly :)
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI want to just take a moment to note how little has changed in how these functions work, at an API level. There’s a strong chance that you could take circa-2006 jQuery-using code and drop in a modern version and have it still work. Granted much more was added later on, as it increased in scope beyond my simple use cases, but almost all of the API that we see here was left intact. I’m definitely proud of the fact that the API was “good enough” to last over the next decade – and beyond.
Now, granted, there are a lot of things I would have loved to change about the API and as time went on it became harder, and harder, to do so (we desperately wanted to avoid breaking backwards compatibility). Regardless, we’re here now and as we can tell from the stats it seems to have been good enough!
This video is processing – it'll appear automatically when it's done.
I think this is great testament to great planning and keeping things simple. Re-bar in construction hasn’t been changed either in 100+ years and is necessary for a having a strong foundation. Well done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI really dis-liked having unnecessary braces. This… unfortunate… style preference plagued us for quite a while and caused all sorts of avoidable logic errors.
This video is processing – it'll appear automatically when it's done.
The only test condition here is if(!b)
So does this mean you’re not opposed to “unnecessary” braces now?
@KevinPrudente: To clarify: I like braces now, I think they provide extra clarity and help to prevent common mistakes.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusWhoops! Assuming that everything was going to be a block was a mistake that we had to rectify later. Unfortunately ‘fixing’ this ended up being a lot harder than we expected! If you have some CSS that’s like “.foo { display: inline }
” and you have a <div class="foo"></div>
the only way you can figure out how it should become “visible” is to insert another div with that class and try to figure out what it’s final state should become. In general show/hide is a great convenience but it’s also a huge case for slow-downs and edge cases. We generally recommend toggling class names now instead.
This video is processing – it'll appear automatically when it's done.
There seems to be a markup bug in this annotation. “…and you have a ? the only way…”
Technically, its us obeying the markdown standard :)
I put the bit in question in backticks so it’ll show up now.
Prototype went the other way (and still does) — we toggle the display
property between none
and an empty string. This means that if you want something hidden initially, you have to apply it as an inline style rather than a display: none
in your stylesheet. Which sucks, but it lets us avoid reading a computed style or something like that.
Tobie had a great rant about how display
sucked for exactly this reason — it was a complex value when it needed to be a simple boolean. Now we have the hidden
attribute. Maybe five years from now we’ll be able to use it.
@Kachkach: Nope! Perhaps it’s easier read as: `this.style.display = (this.$$oldblock ? this.$$oldblock : ‘block’);
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI’ve always been fond of the .wrap() method. It’s one of those things that’s a real pain to write from scratch but is super-convenient to have as a single method. This definitely is a key part of the “progressive enhancement” aspect that jQuery really embraced. Take an existing page and mark it up once you have JS running. Starting with something that works and make it even better if your browser supports it.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusNote that these methods are calling two global methods ‘addEvent’ and ‘removeEvent’ – we’ll get to that later.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusjQuery had proper method chaining from the very beginning. This was something that I was very passionate about as it allowed you to write some very terse code. It even included new conventions like .end() which allowed you to “pop” off of the chain stack.
I honestly can’t remember if I had seem examples of chaining before I wrote this in to jQuery. I know that I was writing a lot of Perl at the time, which has a lot of mechanisms for manipulating arrays (map, grep, etc.). I suspect that that’s what I was most influenced by – but I can’t be 100% sure! The chaining in jQuery has gone on to influence a large number of other libraries, even in other languages, which is pretty cool.
This video is processing – it'll appear automatically when it's done.
Method chaining itself was widely used in JavaScript since the early years of the language, at least with strings and arrays. Here’s a JavaScript 1.1 example – contrived but similar to real code you’d see back in the day:
“chaining! school Old”.split(“ ”).reverse().join(“ ”)
jQuery innovated with a convenient chainable object that referenced DOM elements, and .end() was certainly nifty. I think jQuery also woke people up to the possibility of making their own objects chainable. So I agree, pretty cool. :-)
I think the big thing was that the chains operated against collections, rather than single items. Poking around in the Prototype source I see that they had some forms of chaining-like functionality in 2007, at least. Although all of these methods only operated against a single element. I suspect that this may have been a Ruby-ism -> Prototype -> jQuery transference.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusAll of the $.fn plugin methods are introduced here. This got a lot simpler once we starting using $.prototype as the base point for making plugin extensions. I discuss this a bit more below. Look for the line $.fn = {};
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusThis was a really-cool piece of functionality that I had in jQuery from day 1: the ability to take a HTML fragment and get back a jQuery collection with those DOM nodes in it. This has proved to be incredibly convenient and useful and is still being used today!
For this functionality it existed in an external function (named $C – which more closely matches some of the Prototype-isms of the type). Eventually this moved into the $(…) function call directly, where we looked for usage of < … > and then converted that into DOM elements. In retrospect this functionality probably better existed as an external function, to avoid ambiguities with CSS selectors.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusThe HTML string cleaning logic here is actually very similar to what’s in $C(…) above – I’m surprised these weren’t combined into a single function. They definitely were at a later time, though!
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI had completely forgotten about these. I think I was trying to be cute and support something like: .append(“<div#id.class>”), to make the syntax even shorter. The fact that it’s commented out probably indicates how I thought about it at the time – it never did become integrated into jQuery.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusCSS selectors! Having the bulk of the functionality be contained in this one object was definitely very cute – perhaps too cute. You’ll note that they’re all strings and that below those strings are pushed into an eval() call. I think I was mostly going this route to try and save space, but this came at the expense of run-time costs, which is never a good idea. We changed this to just be normal function calls later.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusWas definitely influenced by XPath when including these custom selectors. Being able to manipulate and sub-select elements in the query results was quite useful!
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI always loved the :visible and :hidden selectors. Being able to quickly find elements that based upon their visibility is so useful. However it’s really come to haunt us as these are some custom CSS selectors that people still use, preventing us from just switching over to using the browser’s native querySelectorAll method wholesale. Oh well…
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusAhh – time for some CSS Selectors-in-JavaScript history! Thankfully Paul Irish wrote up a post charting some of these initial releases:
Javascript CSS Selector Engine Timeline
I was hugely inspired by Ben Nolan’s Behaviour library when working on jQuery. I wanted to make it super-easy to bind events to elements in the page, reducing the syntax required for Behaviour even more!
Archived version of the Behaviour library:
Behaviour : Using CSS selectors to apply Javascript behaviours
Behaviour used Simon Willison’s getElementsBySelector mini-library, which I was also inspired by. My selector engine implementation was directly inspired by his work. I wanted the library to be even more comprehensive, covering nearly all of the important CSS selectors, while also supporting XPath selectors(!!! More on that in a moment…)
I must’ve been made aware of Dean Edwards' cssQuery library some time before I released jQuery, however by that point I had already written my own engine. If memory serves me correctly Dean’s cssQuery was larger than the entirety of jQuery and I was really concerned about file size, so I opted not to switch over to it.
There was a lot of competition in the space. Behaviour + Prototype was popular and four days after I released jQuery Prototype introduced a native “$$(…)” method which took a CSS selector and returned a collection of DOM elements (I’m not sure if I’ve ever gotten confirmation if this was just coincidence of if they rushed to get it in after news of jQuery’s release spread – I’m betting it was just coincidence).
A few months later I wrote a blog post comparing the various state-of-the-art solutions comparing the syntax required to bind an event to multiple elements:
John Resig - Event Selector Showdown
This video is processing – it'll appear automatically when it's done.
Amusing that 10 years later and Ben is, in turn, inspired by jQuery for his new project SceneQuery: (released today!)
Great call, Paul, thank you! :D I’m not sure if the link is displaying for you but SceneQuery is linked to from here:
Oh weird, that’s broken too. Maybe this? SceneQuery.
@jeresig the tweet embed works for me
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusThis is the point on which plugins could be attached to jQuery. This eventually became just a reference to $.prototype, which makes a lot more sense. I had $.fn in from day one so that people could write extensions to jQuery, adding in their own methods. As it turns out this ended up being wildly successful.
The first jQuery plugin was created by Michael Geary on January 25th, just 11 days after the first release of the library (even before this particular version of the file!):
JSON for jQuery | mg.to
More details about the release here:
John Resig - First jQuery Plugin
This video is processing – it'll appear automatically when it's done.
Not just the first plugin, but the worst! What was I thinking? It didn’t really make any sense to attach that JSON plugin to $.fn. As you noted in your blog post, “The chaining of this particular request doesn’t serve many benefits…”
I’m afraid I set a bad example for a whole generation of jQuery plugin developers!
Reminds me of this guy who wanted to turn all popular Node modules into jQuery plugins cuz he couldn’t seem to grasp the idea that coded NEEDN’T BE a jQuery plugin… :-D
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusYou should probably be scratching your head if you’re familiar with CSS. This is actually my meager attempt at mapping some common XPath selectors to CSS! I wrote a whole blog post about this back in 2005, when I was experimenting with this concept:
John Resig - XPath and CSS Selectors
I really liked XPath selectors (they were much more powerful than the then-currently-available CSS selectors) and used them a bunch in my day-to-day coding. In retrospect focusing on CSS was a much better idea as it was more understandable to a wider audience. I believe the XPath selectors were removed by the 1.0 release – I was probably the only person who used them.
This video is processing – it'll appear automatically when it's done.
I loved XPath selectors in jQuery! They were removed in jQuery 1.2, but you provided a plugin for them.
I especially liked being able to go up the DOM tree using ../../
and so on. Fun stuff.
Oh – great context, thank you Karl!
I’m with you, Karl. I loved XPath selectors! They’re so much more powerful than CSS for traversing the DOM. It’s really unfortunate that they aren’t supported in browsers.
What about Document.evaluate() Ben? Is that what you mean?
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI’m kind of amazed that CSS still doesn’t have some equivalent to these selectors – they’re so useful! Selecting inputs by type, or all inputs in aggregate, is such a common operation. Glad we had these built in but it’d be ideal to be able to handle these natively!
This video is processing – it'll appear automatically when it's done.
input[type=“text”] and other attribute selectors were introduced in CSS level 3.
Thanks DS! I’m familiar with attribute selectors in CSS – those actually existed before CSS level 3 (they were in the original CSS 2 spec from 1998). Specifically I’m referring to being able to do something like :button
and being able to match both input elements with a type of button and button elements, as well. Right now you just have to write: input[type=button], button
– but this doesn’t work well if the selector needs to be rooted inside another.
You shall be able to express this as :matches(input[type=button], button)
in CSS Selectors Level 4, assuming that this remains part of the spec. The functionality is available today as :-moz-any()
and :-webkit-any()
in the respective browsers.
Still a far cry from just saying :button
though.
Thanks Aristotle! I haven’t been keeping up with CSS Selectors Level 4 – that sounds awesome!
Level 4 Selectors are going to be super powerful, with a lot of common traversal-type operations and conditional formatting available.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusOofka! These Regexes are pretty gnarly… I’m sorry!
This video is processing – it'll appear automatically when it's done.
for the curious
Regexper(%5Ba-z0-9%5C(%5C)-%5D%2B)%20(%5B~!%5C%7C%5C%24%5E%3D%5D)%20‘%3F%22%3F(%5B%5E’%22%5D)‘%3F%22%3F%20%5C%5D%2F
bad encoding – Regexper
I put @patrickkettner’s link through a URL shortener, seems to work: Regexper
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusNot sure why I was doing .constructor == String. Doing: typeof foo == “string” makes more sense and seems less error prone.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusRe-declaration of variables! Stuff like this went away once I started passing the code through JSLint. I think that was before the 1.0 release, as well.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI just want to note how few comments there are in the original jQuery source. It’s really quite dramatic. Thankfully this is something that was improved upon over time!
That being said I am proud of the fact that jQuery had really good documentation from day 1:
jQuery: Documentation: Overview
This may not seem that surprising but at the time of its release jQuery was pretty much the only JavaScript library with documentation! I distinctly remember when PrototypeJS finally got some (community-created) documentation in January 2007 (a year after jQuery’s release). jQuery had a year-long head-start on documentation!
It bothered me that so few JavaScript libraries had documentation when I was making jQuery and I made a point to write online docs from the get-go. I’m glad I did!
I’m frequently surprised by how few developers will put in the (marginal) extra effort to document their code. So many more people will be able to use and understand if you do!
This video is processing – it'll appear automatically when it's done.
I know it wasn’t wildly popular but there was some unofficial documentation for PrototypeJS back in 10/2005
Ah yeah, I remember those, Sergio! Thank you for the link! I was specifically referring to when the Prototype site redesigned in January 2007 and they had official API docs online: Prototype Javascript Framework
Gotcha. I feel the same way about providing docs.
jQuery was absolutely not the only JavaScript library with documentation when it was released, although the jQuery docs were definitely better than most. Also, I would say that writing good documentation is not at all a small (which is what I assume you mean by “marginal”) amount of effort.
Ah, the PrototypeJS docs from Xmas 2006… This had the roots of what would become, in January, Prototype Core. Mislav, Tobie and I wrote this thing in parallel during the holidays. Great docs were def a major driving force in ramping up jQuery adoption from day 1.
Long long time ago… when I was selecting the standard library to use for our development team, good documentation was definitely one of the strong point for choosing jQuery. I have a feeling this is one of the reason jQuery gained so much popularity at the beginning.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusYou’ll notice that I loved single letter variable names. This was a hard habit to break – but I eventually did! Especially when other developers started to use this code and contribute to it.
This video is processing – it'll appear automatically when it's done.
This style appears to just be a JS version of Pike style (Notes on Programming in C). But I think that style is suited for smaller blocks of code, and doesn’t prescribe single letters for any names in the interface (ie. params).
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusI noticed that I used new Array() and new RegExp() in the code – but I’m not entirely sure why! Why not just use [] and //?
This video is processing – it'll appear automatically when it's done.
You may have been thinking back to the earliest days of old-school JavaScript. Array and object literals didn’t exist in JavaScript 1.0 or 1.1 – they weren’t introduced until 1.2. (Not sure about RegExp literals but could be the same.)
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusIn 2005 there wasn’t a good, standard, way for easily attaching events to DOM elements. Some libraries had this built in, like Prototype, Dojo, and MochiKit, but if you wanted a library that did nothing but that one didn’t really exist! PPK organized a contest to try and find a definitive solution to this problem:
As you can see from the comments I submitted one of the first solutions:
John Resig - Flexible Javascript Events
…and you can see here that I won the contest!
... and the winner is ... - QuirksBlog
As you can see by the comments there, my winning submission was rather… contentious.
I agreed with a lot of the discussion that happened and eventually fell in love with Dean Edwards' solution to this problem (he was one of the judges on the contest!):
addEvent() - My Solution
addEvent() - Follow Up
It’s his code, modified by me, that we eventually see integrated into jQuery as the core addEvent/removeEvent mechanism.
This video is processing – it'll appear automatically when it's done.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by Geniuswhy not elements.events = elements.events || {}
?
This video is processing – it'll appear automatically when it's done.
I would argue that if(!element.events) element.events = {}; is more readable.
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusNever was moved to a module! Still exists in jQuery to this day :)
This video is processing – it'll appear automatically when it's done.
LOL – classic worse is better meme!
@all-up-in-technology: is this the jQuery version of “TODO: conflict resolution”??
Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:
Powered by GeniusHaha – this was to protect against people including Prototype and jQuery in the page in the wrong order. I definitely remember this being a big enough problem that it warranted this check… unfortunately.
This video is processing – it'll appear automatically when it's done.
931